package org.malred.hospital.utils;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.malred.hospital.entity.*;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Objects;
import java.util.Properties;

public class gen {
    public static void main(String[] args) throws IOException {
        String[] entityName = new String[]{
                "doctor",
                "doctorAccount",
                "history",
                "medicine",
                "medicineHistory",
                "medicineList",
                "order",
                "student",
                "studentAccount",
                "studentStatistics",
        };
        Object[] classes = new Object[]{
                new TbDoctor(),
                new TbDoctorAccount(),
                new TbHistory(),
                new TbMedicine(),
                new TbMedicineHistory(),
                new TbMedicineList(),
                new TbOrder(),
                new TbStudent(),
                new TbStudentAccount(),
                new TbStudentStatistics(),
        };

        for (int i = 0; i < entityName.length; i++) {
            GenUtils.genTsType(entityName[i], classes[i].getClass());
        }
    }

    public static void genControl() throws IOException {
        String[] entityName = new String[]{
                "Doctor",
                "DoctorAccount",
                "History",
                "Medicine",
                "MedicineHistory",
                "MedicineList",
                "Order",
                "Student",
                "StudentAccount",
                "StudentStatistics",
        };
        String[] entityFullName = new String[]{
                "org.malred.hospital.entity.TbDoctor",
                "org.malred.hospital.entity.TbDoctorAccount",
                "org.malred.hospital.entity.TbHistory",
                "org.malred.hospital.entity.TbMedicine",
                "org.malred.hospital.entity.TbMedicineHistory",
                "org.malred.hospital.entity.TbMedicineList",
                "org.malred.hospital.entity.TbOrder",
                "org.malred.hospital.entity.TbStudent",
                "org.malred.hospital.entity.TbStudentAccount",
                "org.malred.hospital.entity.TbStudentStatistics",
        };
        String[] route = new String[]{
                "doctor",
                "doctor-account",
                "history",
                "medicine",
                "medicine-history",
                "medicine-list",
                "order",
                "student",
                "student-account",
                "student-statistics",
        };

        for (int i = 0; i < entityFullName.length; i++) {
            GenUtils.genController(
                    entityName[i], entityFullName[i], route[i]
            );
        }
    }
}
